home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1987 / Nov 87 / Using MacApp with C 11⁄16 < prev    next >
Encoding:
Text File  |  1991-03-06  |  4.1 KB  |  117 lines  |  [TEXT/GEOL]

  1. Item    8391545                         16-Nov-87        16:07
  2.  
  3. From:   D0830                           Data Translation, Dev, R Burger
  4.  
  5. To:     MACAPP$                         MacApp Interest List
  6.  
  7. Sub:    Response to C+MacApp Cross Dev
  8.  
  9. Happiness = MPW C + Pascal + MacApp
  10.  
  11. I recently tackled the problem of integrating MPW C code into
  12. our MacApp/MPW Pascal programming environment and came up
  13. with what I believe is a fairly clean solution.  There are
  14. lots of subtle issues to deal with, but all you'll need do
  15. is modify a few of MacApp's make files and you'll be automatically
  16. MABuilding complete C+Pascal+MacApp applications within minutes.
  17.  
  18. To the MacApp.make1 file in 'MacApp Make Files':
  19.  
  20. 1)  Change the .p.o rule near the bottom of the file to read:
  21.  
  22.     .p.o    ƒ   .p
  23.         echo  Compiling {default}.p
  24.         Pascal {depDir}{default}.p {Debugging} {PascalOptions}  ∂
  25.                 {POptions} {Search} -d qNeedsROM128K={NeedsROM128K}  ∂
  26.                 -i "{SrcMacApp}" -k "{LoadMacApp}" -o {targDir}{default}.p.o
  27.  
  28.     I have added the {POptions} and {Search} strings to allow the
  29.     specification of additional Pascal compilation options (such as
  30.     -mc68020) and a .p interface file search string.
  31.  
  32. 2)  Add the following .c.o default rule to the bottom of the file:
  33.  
  34.     .c.o    ƒ   .c
  35.         echo  Compiling {default}.c
  36.         C {depDir}{default}.c {COptions} {Search} -o {targDir}{default}.c.o
  37.  
  38.     This default rule will handle automatic compilation of C files
  39.     for you.  Of course, you'll have to add additional dependencies,
  40.     like header dependencies, yourself in {YourApp}.make.
  41.     Again, the {COptions} string is for C compilation options and the
  42.     {Search} string is a search path for #included .h files.
  43.  
  44. To the MacApp.make2 file in 'MacApp Make Files':
  45.  
  46. 1)  Change the order of object files in the Link command to:
  47.             "M{AppName}.p.o"  ∂
  48.             "U{AppName}.p.o"  ∂
  49.             {OtherLinkFiles}  ∂
  50.             "{ObjMacApp}MacAppLib.o"  ∂
  51.             {NeededSysLibs}   ∂
  52.             {LinkDebug}
  53.  
  54.     This is important.  MacApp applications use a Pascal main routine.
  55.     In order to link C subroutines into the system, the Pascal main
  56.     routine must be linked BEFORE CRuntime.o, part of {NeededSysLibs}.
  57.  
  58. 2)  Add '-w' to the Link command, or you'll see a lot of
  59.     duplicate symbols.
  60.  
  61. To the MacApp.opt.make2 file in 'MacApp Make Files':
  62.  
  63. 1)  Change the order of object files in the Link command to:
  64.             "M{AppName}.p.o"  ∂
  65.             "U{AppName}.p.o"  ∂
  66.             {BuildingBlockObjs}  ∂
  67.             {OtherLinkFiles}  ∂
  68.             {MacAppObjs}  ∂
  69.             {DebugFiles}  ∂
  70.             {NeededSysLibs}  ∂
  71.             {LinkDebug}
  72.  
  73. 2)  Add '-w' to the Link command.
  74.  
  75. To {YourApp}.make file(s):
  76.  
  77. 1)  Define special C compilation options in COptions, as in:
  78.         COptions = -mc68020 -mc68881
  79.  
  80. 2)  Define special Pascal compilation options in POptions.
  81.  
  82. 3)  Define the search path for .h header files and .p interface files in
  83.     Search, as in:
  84.         Search = -i "{MPW}Display:"  -i "{MPW}Support:"
  85.  
  86. 4)  Define NeededSysLibs as follows:
  87.         NeededSysLibs = ∂
  88.             "{CLibraries}StdCLib.o"    ∂
  89.             "{CLibraries}CSaneLib.o"   ∂
  90.             "{CLibraries}Math.o"       ∂
  91.             "{CLibraries}CRuntime.o"   ∂
  92.             "{CLibraries}CInterface.o" ∂
  93.             "{Libraries}Interface.o"   ∂
  94.             "{PLibraries}PasLib.o"
  95.  
  96.     If one of more of these libraries is not needed for the link,
  97.     you can remove them if you wish.
  98.  
  99.  
  100. That's all there is to it.  While I may not have covered all the
  101. bases with these fixes, I've been quite happy with the way things
  102. have been running so far.  And it WORKS, which is always an
  103. important consideration.
  104.  
  105. Of course, there are lots of issues in integrating C and Pascal
  106. code (lots and lots and lots), and you won't be able to pass
  107. messages to objects in C, but that's another story...
  108.  
  109. I hope these updates help.  Send me your problems or comments.
  110. I can't guarantee that the above changes will work with anything
  111. besides MPW v2.0 and MacApp v1.1.1.
  112.  
  113. Roberto Sierra
  114. Data Translation, Inc.
  115.  
  116.  
  117.